<template>
  <view class="form-item rate-item">
    <uni-rate
      v-model="form[item.__vModel__]"
      :max="item.max || 5"
      :disabled="item.disabled"
      :allow-half="item['allow-half'] || false"
      :show-score="item['show-score'] || false"
      active-color="#ff1379"  
	  color="#9e9e9e"
      size="28"               
      gutter="6"               
      @change="onRateChange(item.__vModel__, $event)"
      class="custom-rate"
    />
  </view>
</template>

<script>
export default {
  name: 'RateField',
  props: {
    item: { type: Object, required: true },
    form: { type: Object, required: true }
  },
  methods: {
    onRateChange(key, val) {
      console.log(`评分字段 ${key} 变化:`, val)
      this.$set(this.form, key, val)
    }
  }
}
</script>

<style scoped>
.form-item.rate-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
}
.custom-rate {
  margin-right: 8px;
}
</style>
